/**
 * 
 */
package com.zc.spring.reflect;

import java.lang.reflect.InvocationTargetException;
import java.util.Scanner;

/**
 * @author ZhangCheng
 * @time 2019年10月31日
 */
public class Test {

	/**
	 * @param args
	 * @throws ClassNotFoundException
	 * @throws SecurityException
	 * @throws NoSuchMethodException
	 * @throws InvocationTargetException
	 * @throws IllegalArgumentException
	 * @throws IllegalAccessException
	 * @throws InstantiationException 
	 */
	public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, SecurityException,
			IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException {
		Scanner sc = new Scanner(System.in);
		String fruitName = sc.next();
		Class c;
		if ("香蕉".equals(fruitName)) {
			c = Class.forName("com.zc.reflect.Banana");
			
		} else if ("苹果".equals(fruitName)) {
			c = Class.forName("com.zc.reflect.Apple");

		} else if ("梨子".equals(fruitName)) {
			c = Class.forName("com.zc.reflect.Peer");
			
		} else {
			c = Class.forName("com.zc.reflect.UnKnowFruit");
			
		}
		c.getDeclaredMethod("createFruit").invoke(c.newInstance(), null);
	}
}
